package decoration;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @Author: linKe
 * @Date: 2022/1/15 9:52
 * @FileName: Client
 * @version: 1.0
 * @Description: 客户端测试类
 * 装饰设计模式
 * 增强方法实现   将文本转换成小写
 */
public class Client {
    public static void main(String[] args) throws IOException {
        // 创建饮料接口对象 酒的实现类
        Beverage mochaWine = new Wine();
        // 已有实现类 转换成装饰的实现类 并将自身传入
        mochaWine = new Mocha(mochaWine);
        // 调用增强后的方法   描述
        System.out.println(mochaWine.getDescription() + " : " + mochaWine.cost());

        // done
        testInput();
    }

    public static void testInput() throws IOException {
        File file = new File("C:\\Users\\Administrator\\Desktop\\aaa.txt");
        // 增强输入流转换成 小写替换的输入流
        LowerCaseInputStream lcis = new LowerCaseInputStream(new FileInputStream(file));
        int i = -1;
        while((i = lcis.read()) != -1) {
            System.out.print((char) i);
            // aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        }

        lcis.close();
    }
}
